package org.oslims.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.google.gwt.validation.client.NotEmpty;
import com.google.gwt.validation.client.NotNull;

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE_OF_SAMPLE")
public abstract class AbstractSample extends AbstractBaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2900966343952296404L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	private String code;

	@ManyToOne
	@JoinColumn(name = "SAMPLE_TYPE_FK")
	private SampleType sampleType;

	@NotEmpty
	private String description;

	@NotEmpty
	private String origin;

	@Temporal(TemporalType.TIMESTAMP)
	private Date samplingTime;

	private String storagePlace;

	@NotEmpty
	private String state;

	@ManyToMany
	@NotNull
	private List<Request> requests = new ArrayList<Request>();

	@OneToMany(mappedBy = "sample")
	List<AnalysisResult> analysisResults = new ArrayList<AnalysisResult>();

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public SampleType getSampleType() {
		return sampleType;
	}

	public void setSampleType(SampleType sampleType) {
		this.sampleType = sampleType;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getOrigin() {
		return origin;
	}

	public void setOrigin(String origin) {
		this.origin = origin;
	}

	public Date getSamplingTime() {
		return samplingTime;
	}

	public void setSamplingTime(Date samplingTime) {
		this.samplingTime = samplingTime;
	}

	public List<AnalysisResult> getAnalysisResults() {
		return analysisResults;
	}

	public void setAnalysisResults(List<AnalysisResult> analysisResults) {
		this.analysisResults = analysisResults;
	}

	public void setRequests(List<Request> requests) {
		this.requests = requests;
	}

	public List<Request> getRequests() {
		return requests;
	}

	public void setStoragePlace(String storagePlace) {
		this.storagePlace = storagePlace;
	}

	public String getStoragePlace() {
		return storagePlace;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getState() {
		return state;
	}

}
